package com.example.demo.dismanage.controller;

import com.example.demo.dismanage.service.DisPaiService;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Transactional
@CrossOrigin
public class DisPaiController {

    private Logger log = Logger.getLogger(DisPaiController.class);

    @Autowired
    private DisPaiService disPaiService;
    /**
     * @Description 根据条件查询所有调度信息
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryAllPaiDis",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllPaiDis(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = disPaiService.queryAllPaiDis(param);
        return statusMap;
    }

    /**
     * @Description 派车返回
     * @Author zhangxue
     * @Date 11:25 2018/7/31
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/SaveFanInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> SavePaiInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = disPaiService.SaveFanInfo(param);
        return statusMap;
    }

    /**
     * @Description 修改车辆返回信息
     * @Author zhangxue
     * @Date 11:25 2018/7/31
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/EditFan",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> EditFan(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = disPaiService.EditFan(param);
        return statusMap;
    }

    /**
     * @Description 派车返回(手机端接口)
     * @Author zhangxue
     * @Date 11:25 2018/7/31
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/SaveFanInfoPhone",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> SaveFanInfoPhone(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = disPaiService.SaveFanInfoPhone(param);
        return statusMap;
    }

    /**
     * @Description 根据条件查询车辆返回信息
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryAllFanDis",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllFanDis(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = disPaiService.queryAllFanDis(param);
        return statusMap;
    }

    /**
         * @Description 查询所有约车店面
         * @Author zhangxue
         * @Date 10:42 2018/10/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/queryAllYueStore")
    @ResponseBody
    public String queryAllYueStore(){
        JSONObject js= new JSONObject();
        Map<String,Object> resultMap = new HashMap<String, Object>();
        Map<String,Object> param = new HashMap<String, Object>();
        List<Map<String,Object>> resultList = disPaiService.queryAllYueStore(param);
        resultMap.put("data",resultList);
        js = JSONObject.fromObject(resultMap);
        return js.toString();
    }

    /**
     * @Description 车辆返回信息数据统计
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryAllFanData",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllFanData(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = disPaiService.queryAllFanData(param);
        return statusMap;
    }

}
